﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rappelz.GameServer
{
    public class MonsterBase
    {

        public const int NUMBER_OF_TRIGGERS = 6;
        public const int NUMBER_OF_SKILLS = 6;


        public enum FightType : int
        {
            Normal = 0,
            Environment = 1,
            DungeonConnector = 2,
            Boss = 3,
            Agent = 4,
            AutoTrap = 5,
            NonAttacker = 6,
        }

        public enum AttackTypeFlag : int
        {
            FirstAttack = 1,
            GroupFirstAttack = 2,
            ResponseCasting = 4,
            ResponseRace = 8,
            ResponseBattle = 16,
        }

        public enum MonsterType : int
        {
            Normal = 0,
            Warrior = 1,
            Magician = 2,
            Summoner = 3,
            Reserved1 = 4,
            Reserved2 = 5,
            Reserved3 = 6,
            Reserved4 = 7,
            Reserved5 = 8,
            EventGuardian = 9,
            Enhance = 11,
            FieldSubBoss = 12,
            HuntaholicLv1 = 15,
            HuntaholicLv2 = 16,
            HuntaholicLv3 = 17,
            HuntaholicBoss = 18,
            Dungeon = 21,
            DungeonSubBoss = 22,
            C_Boss = 31,
            B_Boss = 32,
        }

        public enum MonsterRace : int
        {
            DungeonCore = 20000,
            DungeonConnector = 20001,
        }

        public enum TriggerType : int
        {
            None = 0,
            HPBelowOnce = 1,
            HPBelowAlways = 2,
            TimeOnce = 3,
            TimeAlways = 4,
            TimeAlwaysIncludeStart = 5,
        }

        public class MonsterTrigger
        {
            public int id;
            public float[] value = new float[2];
            public string script;
        }

        public class MonsterItemDropInfo
        {
            public int item_id;                         // 0x00
            public int percentage;                      // 0x04
            public short min_count;                     // 0x08
            public short max_count;                     // 0x0A
            public short min_level;                     // 0x0C
            public short max_level;                     // 0x0E
        }



        public class MonsterSkillInfo
        {
            public int skill_id;
            public int skill_lvl;
            public float skill_probability;
        }

        public int uid;                             // 0x0
        public int monster_group;// Data           :   this+0x4, Member, Type: int, 
        public int monster_type;// Data           :   this+0x8, Member, Type: int, 
        public int name_id;// Data           :   this+0xC, Member, Type: int, 
        public int race;// Data           :   this+0x10, Member, Type: int, 
        public int group;// Data           :   this+0x14, Member, Type: int, 
        public int transform_level;// Data           :   this+0x18, Member, Type: int, 
        public int level;// Data           :   this+0x1C, Member, Type: int, 
        public float size;// Data           :   this+0x20, Member, Type: float, size
        public float scale;// Data           :   this+0x24, Member, Type: float, scale
        public int walk_type;// Data           :   this+0x28, Member, Type: int, 
        public int visible_range;// Data           :   this+0x2C, Member, Type: int, 
        public int chase_range;// Data           :   this+0x30, Member, Type: int, 
        public int magic_type;// Data           :   this+0x34, Member, Type: int, 
        public int attack_type;// Data           :   this+0x38, Member, Type: int, 
        public int hp;// Data           :   this+0x3C, Member, Type: int, hp
        public int mp;// Data           :   this+0x40, Member, Type: int, mp
        public int attack_point;// Data           :   this+0x44, Member, Type: int, 
        public int magic_point;// Data           :   this+0x48, Member, Type: int, 
        public int defence;// Data           :   this+0x4C, Member, Type: int, 
        public int magic_defence;// Data           :   this+0x50, Member, Type: int, 
        public int attack_speed;// Data           :   this+0x54, Member, Type: int, 
        public int attack_speed_type;// Data           :   this+0x58, Member, Type: int, 
        public int casting_speed;// Data           :   this+0x5C, Member, Type: int, 
        public int accuracy;// Data           :   this+0x60, Member, Type: int, 
        public int avoid;// Data           :   this+0x64, Member, Type: int, 
        public int magic_accuracy;// Data           :   this+0x68, Member, Type: int, 
        public int magic_avoid;// Data           :   this+0x6C, Member, Type: int, 
        public int taming_code;// Data           :   this+0x70, Member, Type: int, 
        public float taming_percentage; // Data           :   this+0x74, Member, Type: class c_fixed<10000>, taming_percentage
        public float taming_exp_adjust;// Data           :   this+0x7C, Member, Type: float, taming_exp_adjust
        public int exp;// Data           :   this+0x80, Member, Type: int, 
        public int exp_2;// Data           :   this+0x84, Member, Type: int, 
        public int jp;// Data           :   this+0x88, Member, Type: int, 
        public int jp_2;// Data           :   this+0x8C, Member, Type: int, 
        public int stat_id;// Data           :   this+0x90, Member, Type: int, 
        public int ability;// Data           :   this+0x94, Member, Type: int, 
        public int walk_speed;// Data           :   this+0x98, Member, Type: int, 
        public int run_speed;// Data           :   this+0x9C, Member, Type: int, 
        public int attack_range;// Data           :   this+0xA0, Member, Type: int, 
        public int hidesense_range;// Data           :   this+0xA4, Member, Type: int, 
        public int fight_type;                                          // 0xA8
        public MonsterTrigger[] trigger = new MonsterTrigger[NUMBER_OF_TRIGGERS]; // 0xAC
        public int gold_drop_percentage;// Data           :   this+0x6F4, Member, Type: int, 
        public int gold_min;// Data           :   this+0x6F8, Member, Type: int, 
        public int gold_max;// Data           :   this+0x6FC, Member, Type: int, 
        public int gold_min_2;// Data           :   this+0x700, Member, Type: int, 
        public int gold_max_2;// Data           :   this+0x704, Member, Type: int, 
        public int chaos_drop_percentage;// Data           :   this+0x708, Member, Type: int, 
        public int chaos_min;// Data           :   this+0x70C, Member, Type: int, 
        public int chaos_max;// Data           :   this+0x710, Member, Type: int, 
        public int chaos_min_2;// Data           :   this+0x714, Member, Type: int, 
        public int chaos_max_2;// Data           :   this+0x718, Member, Type: int, 
        public int[] drop_item_id = new int[10];// Data           :   this+0x71C, Member, Type: int[0xA], 
        public int[] drop_percentage = new int[10]; // Data           :   this+0x744, Member, Type: int[0xA], 
        public short[] drop_min_count = new short[10];// Data           :   this+0x76C, Member, Type: short[0xA], 
        public short[] drop_max_count = new short[10];// Data           :   this+0x780, Member, Type: short[0xA], 
        public short[] drop_min_level = new short[10];// Data           :   this+0x794, Member, Type: short[0xA], 
        public short[] drop_max_level = new short[10];// Data           :   this+0x7A8, Member, Type: short[0xA], 
        public MonsterSkillInfo[] skill_info = new MonsterSkillInfo[NUMBER_OF_SKILLS];
        public List<MonsterBase.MonsterItemDropInfo> item_drop_list = new List<MonsterItemDropInfo>();

    }


    public class dbMonster : MonsterBase
    {
// Data           :   this+0x808, Member, Type: struct _decimal_variant, dv_size
// Data           :   this+0x818, Member, Type: struct _decimal_variant, dv_scale
// Data           :   this+0x828, Member, Type: struct _decimal_variant, dv_attack_range
// Data           :   this+0x838, Member, Type: struct _decimal_variant, dv_hidesense_range
// Data           :   this+0x848, Member, Type: struct _decimal_variant[0xA], dv_drop_percentage
// Data           :   this+0x8E8, Member, Type: struct _decimal_variant, dv_taming_percentage
// Data           :   this+0x8F8, Member, Type: struct _decimal_variant, dv_taming_exp_mod
// Data           :   this+0x908, Member, Type: struct _decimal_variant[0x6], dv_skill_probability
// Data           :   this+0x968, Member, Type: struct _decimal_variant[0x2][0x6], dv_trigger
        public byte f_first_attack;//   Data           :   this+0xA28, Member, Type: char, f_first_attack
        public byte f_group_first_attack;//           :   this+0xA29, Member, Type: char, 
        public byte f_response_casting;//Data           :   this+0xA2A, Member, Type: char, 
        public byte f_response_race;//Data           :   this+0xA2B, Member, Type: char, 
        public byte f_response_battle;//Data           :   this+0xA2C, Member, Type: char, 
        public int location_id;//Data           :   this+0xA30, Member, Type: int, location_id
        public int local_flag;//Data           :   this+0xA34, Member, Type: int, local_flag

    }

    public class dbMonsterItemDrop
    {
        public int nID;                                                                                     // 0x04
        public MonsterBase.MonsterItemDropInfo[] item_drop = new MonsterBase.MonsterItemDropInfo[10];       // 0x08
        public float[] dv_drop_percentage = new float[10];                                                  // 0xA8
    }
}
